{
    "cells": [
        {
            "attachments": {},
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "# FullControl 1-minute demo\n",
                "\n",
                "#### run all cells in this notebook in order (keep pressing shift+enter)\n",
                "\n",
                "this quick demo shows how a design can be created with a list of points for nozzle movement with or without extrusion\n",
                "\n",
                "the design is visually previewed, then gcode is created for a specific printer and saved to a file\n",
                "\n",
                "for more information, see the [FullControl overview notebook](https://colab.research.google.com/github/FullControlXYZ/fullcontrol/blob/master/tutorials/colab/overview_colab.ipynb)\n",
                "\n",
                "<*this document is a jupyter notebook - if they're new to you, check out how they work:\n",
                "[link](https://www.google.com/search?q=ipynb+tutorial),\n",
                "[link](https://jupyter.org/try-jupyter/retro/notebooks/?path=notebooks/Intro.ipynb),\n",
                "[link](https://colab.research.google.com/)*>\n",
                "\n",
                "*run all cells in this notebook in order (keep pressing shift+enter)*\n",
                "\n",
                "#### first, import fullcontrol to have access to its capabilities"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "if 'google.colab' in str(get_ipython()):\n  !pip install git+https://github.com/FullControlXYZ/fullcontrol --quiet\nimport fullcontrol as fc"
            ]
        },
        {
            "attachments": {},
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "#### create and preview a design (a list of steps telling the printer what to do)"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "# create an empty list called steps\n",
                "steps=[]\n",
                "# add points to the list\n",
                "steps.append(fc.Point(x=40,y=40,z=0.2))\n",
                "steps.append(fc.Point(x=50,y=50))\n",
                "steps.append(fc.Point(x=60,y=40))\n",
                "# turn the extruder on or off\n",
                "steps.append(fc.Extruder(on=False))\n",
                "steps.append(fc.Point(x=40,y=40,z=0.4))\n",
                "steps.append(fc.Extruder(on=True))\n",
                "steps.append(fc.Point(x=50,y=50))\n",
                "steps.append(fc.Point(x=60,y=40))\n",
                "# transform the design into a plot\n",
                "fc.transform(steps, 'plot')"
            ]
        },
        {
            "attachments": {},
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "#### set filename, printer and print settings"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "filename = 'my_design'\n",
                "printer = 'ender_3' \n",
                "# printer options: generic, ultimaker2plus, prusa_i3, ender_3, cr_10, bambulab_x1, toolchanger_T0, toolchanger_T1, toolchanger_T2, toolchanger_T3\n",
                "print_settings = {'extrusion_width': 0.5,'extrusion_height': 0.2, 'nozzle_temp': 210, 'bed_temp': 40, 'fan_percent': 100}\n",
                "# 'extrusion_width' and 'extrusion_height' are the width and height of the printed line)"
            ]
        },
        {
            "attachments": {},
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "#### save gcode file to the same directory as this notebook\n",
                "\n",
                "do not edit this line of code - it uses values defined in the previous code cells\n",
                "\n",
                "make sure you execute the previous cells before running this one"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "fc.transform(steps, 'gcode', fc.GcodeControls(printer_name=printer, save_as=filename, initialization_data=print_settings))"
            ]
        },
        {
            "attachments": {},
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "#### get creative!\n",
                "\n",
                "check out [other tutorials](https://colab.research.google.com/github/FullControlXYZ/fullcontrol/blob/master/tutorials/colab/contents_colab.ipynb) to see how to create designs like this gear/thread example with just one line of code"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "steps = [fc.polar_to_point(centre=fc.Point(x=0, y=0, z=i*0.005), radius=10, angle=i*4.321) for i in range(1000)]\n",
                "fc.transform(steps, 'plot', fc.PlotControls(neat_for_publishing=True, zoom=0.7))"
            ]
        },
        {
            "attachments": {},
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "#### random mesh example"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "from math import tau\n",
                "from random import random\n",
                "steps=[fc.polar_to_point(centre=fc.Point(x=0, y=0, z=i*0.001), radius=10+5*random(), angle=i*tau/13.8) for i in range(4000)]\n",
                "fc.transform(steps, 'plot', fc.PlotControls(neat_for_publishing=True, zoom=0.7))"
            ]
        }
    ],
    "metadata": {
        "kernelspec": {
            "display_name": "Python 3 (ipykernel)",
            "language": "python",
            "name": "python3"
        },
        "language_info": {
            "codemirror_mode": {
                "name": "ipython",
                "version": 3
            },
            "file_extension": ".py",
            "mimetype": "text/x-python",
            "name": "python",
            "nbconvert_exporter": "python",
            "pygments_lexer": "ipython3",
            "version": "3.11.3"
        },
        "vscode": {
            "interpreter": {
                "hash": "2b13a99eb0d91dd901c683fa32c6210ac0c6779bab056ce7c570b3b366dfe237"
            }
        }
    },
    "nbformat": 4,
    "nbformat_minor": 4
}
